#include <stdio.h>
#include <wiringPi.h>
#define PIN 7

void incrementsecond(void);
void printtime(void);
void settime(unsigned char hour,unsigned char min,unsigned char sec);

int main (void)
{
    wiringPiSetup () ;
    pinMode (PIN, INPUT) ;
	pullUpDnControl(PIN, PUD_UP) ;

	settime(8,58,55);
	printtime();

	while(1)
		{
			while ( 1 == digitalRead(PIN))
				{
				delay(1);
				}
			while ( 0 == digitalRead(PIN))
				{
				delay(1);
				}
			incrementsecond();
			printtime();
		}
				
 return 0 ;
}






unsigned char   seconds,minutes,hours;

void printtime(void)
{
  printf("The time is %d:%d:%d\n",hours,minutes,seconds);
}

void settime(unsigned char hour,unsigned char min,unsigned char sec)
{
seconds = sec;
minutes = min;
hours = hour;
}

AdjustOverflowHours()
{
if (hours == 24)
	{
	hours=0;
	//incrementday();
	}

}

incrementhour()
{
 hours++;
AdjustOverflowHours();
}

AdjustOverflowMinutes()
{
if (minutes == 60)
	{
	minutes=0;
	incrementhour();
	}

}

incrementminute()
{
 minutes++;
AdjustOverflowMinutes();
}


AdjustOverflowSeconds()
{
if (seconds == 60)
	{
	seconds=0;
	incrementminute();
	}
}

void incrementsecond(void)
{
seconds++;
AdjustOverflowSeconds();
}

